
import { Howl } from 'howler'

let _music = {

    instance: null,

    load: function (file) {

        if (this.instance) {
            return
        }

        let that = this
        this.instance = new Howl({
            src: [file],
            loop: true,
            preload: true,
            autoplay: true,
        })

        this.instance.on('load', () => {
            that.instance.play();
        })
    },

    unload: function () {

        if (!this.instance) {
            return
        }

        let that = this
        this.instance.on('unload', () => {
            that.instance.unload();
        })
    }


}

export default _music
